﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace SongClassifier
{
    public class GraphDraw
    {
        public static void Draw(Graphics g, int[] value, int x0, int y0, int maxV)
        {
            if (value == null)
                return;

            Pen pen = new Pen(Color.Blue, 1f);
            g.Clear(Color.White);
            int lastx = 0, lasty = 0;
            double scale = y0 / (maxV + 0f);
            if (maxV == 0)
                scale = 0;
            for (int x = 0; x < value.Length; x++)
            {
                int y = -(int)(value[x] * scale);
                g.DrawLine(pen, new Point(x0 + lastx, y0 + lasty), new Point(x0 + x, y0 + y));
                lastx = x;
                lasty = y;
            }
        }
    }
}
